package com.lg.spring;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author by Mr. Li 2020/6/13 19:13
 */
public class SpringClient {
    public static void main(String[] args) {
        // 获取资源加载器
        Resource resource = new ClassPathResource("applicationContext.xml");

        // 创建加载bean的工厂
        DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();

        // 解析xml文件
        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(defaultListableBeanFactory);

        // 真正的加载 初始化bean
        xmlBeanDefinitionReader.loadBeanDefinitions(resource);

        StudentList studentList = (StudentList) defaultListableBeanFactory.getBean("studentList");

        System.out.println(studentList.getStudent());


    }
}
